package com.acme.task6;

public class CommentSkipper {
	static final String ONE_COMMENT_OPEN = "//";
	static final String ONE_COMMENT_CLOSE = "\n";
	static final String MULTI_COMMENT_OPEN = "/*";
	static final String MULTI_COMMENT_CLOSE = "*/";
	
	public static void main(String[] args) {
		if (args.length == 0) {
			System.out.println("Empty argument list");
			return;
		}
		
		String str = args[0];
		printTExtWithoutComments(str);
	}
	
	static void printTExtWithoutComments(String str) {
		boolean inOneLineComment = false;
		boolean inMultiLineComment = false;
		
		for (int i = 0; i < str.length()-1; i++) {
			String s = str.substring(i, i+2);
						
			switch (s) {
			case ONE_COMMENT_OPEN:
				inOneLineComment = true;
				i++;
				break;
			case MULTI_COMMENT_OPEN:
				inMultiLineComment = true;
				i++;
				break;
			}
			
			if (!(inOneLineComment || inMultiLineComment)) {
				System.out.print(str.charAt(i));
			}

			if (s.substring(0, 1).equals(ONE_COMMENT_CLOSE) && inOneLineComment) {
				inOneLineComment = false;
			}
			
			if(s.equals(MULTI_COMMENT_CLOSE))
			{
				inMultiLineComment = false;
				i++;
			}
		}
		if (!(inOneLineComment && inMultiLineComment))
			System.out.print(str.charAt(str.length()-1));
		
		System.out.println();
	}
}
